<%@page import="com.utils.Constants"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:choose>
	<c:when test="${empty listAccount}">
		<p style='text-align: center;'>No Records Available</p>
	</c:when>
	<c:otherwise>
		<div class="col1">
			<span class="col-name">ID</span>
		</div>
		<div class="col2">
			<span class="col-name">username</span>
		</div>
		<div class="col3">
			<span class="col-name">Tool</span>
		</div>
		<div class="clear" />
		<div id="list-data">
			<c:forEach var="acc" items="${listAccount}">
				<div class="col1">${acc.id}</div>
				<div class="col2">${acc.usernameUrlDecode}</div>
				<div class="col3">
					<a href="javascript:void(0);" 
					onclick ="showEditFormAccount(${acc.id}, '${acc.username}', '${acc.password}', '${acc.email}' );return false;">
						<div class="edit-button">Edit</div>
					</a> <a	href="javascript:void(0);" onclick="showConfirmDialog(${acc.id})">
						<div class="delete-button">Delete</div>
					</a>
				</div>
			</c:forEach>
			<div class="clear" />
		</div>
	</c:otherwise>
</c:choose>

<c:if test="${page > 1}">
	<div style='text-align: center'>
		<c:set var="next" value="${start + display}"></c:set>
		<c:set var="prev" value="${start - display}"></c:set>
		<c:set var="current" value="${(start/display) + 1}"></c:set>
		<c:set var="datastrPrv" value="start=${prev}&page=${page}"></c:set>
		<c:set var="datastrNext" value="start=${next}&page=${page}"></c:set>

		<!-- Hien thi trang Previous -->
		<c:if test="${current != 1}">
			&nbsp;&nbsp;<b><a href="javascript:void(0)" onclick="readAccount('${datastrPrv}');">Previous</a></b>&nbsp;&nbsp;
		</c:if>
		<!-- Hien thi so link -->
		<c:forEach begin="1" end="${page}" var="i" step="1" varStatus="loop">
			<c:choose>
				<c:when test="${current != i}">
					<c:set var="datastrPage" value="start=${display*(i-1)}&page=${page}"></c:set>
					&nbsp;&nbsp;<b><a href="javascript:void(0)" onclick="readAccount('${datastrPage}');">${i}</a></b>&nbsp;&nbsp;
				</c:when>
				<c:otherwise>
					&nbsp;&nbsp;<b>${i}</b>&nbsp;&nbsp;
				</c:otherwise>
			</c:choose>
		</c:forEach>
		<!-- Hien thi trang Next -->
		<c:if test="${current != page}">
 			&nbsp;&nbsp;<b><a href="javascript:void(0)" onclick="readAccount('${datastrNext}');">Next</a></b>&nbsp;&nbsp;
 		</c:if>
	</div>
</c:if>



